package action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import entitybean.system_log.EntitybeanSystem_Log;
import form.System_LogForm;

import service.service_admin.Service_Admin;
import service.service_public.Service_Public;
import tools.InterfaceForResultSetToList;
import tools.PageBeanPlus;
import view.ViewOc_Voyage;
import view.ViewSystem_Log;

public class Action_System_Log extends DispatchAction{
	private Service_Admin service_admin;
	private Service_Public service_public;
	public Service_Admin getService_admin() {
		return service_admin;
	}
	public void setService_admin(Service_Admin serviceAdmin) {
		service_admin = serviceAdmin;
	}
	public Service_Public getService_public() {
		return service_public;
	}
	public void setService_public(Service_Public servicePublic) {
		service_public = servicePublic;
	}
	public ActionForward admin_init_system_log(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		System.out.println("admin_init_system_log");
		System_LogForm f=(System_LogForm)form;
		System.out.println("f.getCurrentpage()="+f.getCurrentpage());
		System.out.println("f.getRowcountperpage()="+f.getRowcountperpage());
		String sql="select ID,LOG_KIND,IP,UPDATE_TIME,FINISH,(SELECT USERNAME FROM OC_USER_NAME WHERE ID=SYSTEM_LOG.USER_ID)AS USERNAME from SYSTEM_LOG order by id DESC";
		PageBeanPlus pagebeanplus = new PageBeanPlus("oracle", "sql", sql,
				Integer.valueOf(f.getRowcountperpage()), Integer
						.valueOf(f.getCurrentpage()), "loadrichtext()");
		InterfaceForResultSetToList interfaceforresultsettolist = new InterfaceForResultSetToList();
		List<ViewSystem_Log> list = interfaceforresultsettolist
		.ViewSystem_Log(pagebeanplus.getFormatqueryresultset());
		
		request.setAttribute("pagebeanplus", pagebeanplus);// 设置传递到页面的数据
		request.setAttribute("list", list);
		request.setAttribute("system_logform", f);
		System.out.println("list.size()" + list.size());
		return mapping.findForward("success");		
		
	}
	public ActionForward admin_load_system_log(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		System.out.println("admin_load_system_log");
		System_LogForm f=(System_LogForm)form;
		String id=f.getId();
		EntitybeanSystem_Log e=this.service_admin.Find_System_Log_By_Id(Integer.valueOf(id));
		request.setAttribute("e", e);
		return mapping.findForward("success");		
		
	}
	
	
	
	public ActionForward admin_search_system_log(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		System.out.println("admin_search_system_log");
	
		System_LogForm f=(System_LogForm)form;
		System.out.println("f.getCurrentpage()="+f.getCurrentpage());
		System.out.println("f.getRowcountperpage()="+f.getRowcountperpage());
		String sql="select ID,LOG_KIND,IP,UPDATE_TIME,FINISH,(SELECT USERNAME FROM OC_USER_NAME WHERE ID=SYSTEM_LOG.USER_ID)AS USERNAME from SYSTEM_LOG order by id DESC";
		PageBeanPlus pagebeanplus = new PageBeanPlus("oracle", "sql", sql,
				Integer.valueOf(f.getRowcountperpage()), Integer
						.valueOf(f.getCurrentpage()), "loadrichtext()");
		InterfaceForResultSetToList interfaceforresultsettolist = new InterfaceForResultSetToList();
		List<ViewSystem_Log> list = interfaceforresultsettolist
		.ViewSystem_Log(pagebeanplus.getFormatqueryresultset());
		
		request.setAttribute("pagebeanplus", pagebeanplus);// 设置传递到页面的数据
		request.setAttribute("list", list);
		request.setAttribute("system_logform", f);
		System.out.println("list.size()" + list.size());
		return mapping.findForward("success");		
		
	}
}
